<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Prikaz</title>
</head>

<body style="text-align: center">

<?php
error_reporting(0);
session_start();
if ($_SESSION["adminusername"]=="")
{
    echo "Niste prijavljeni kao administrator";
    exit;
}
require_once( 'DBConfig.php' ); 
$link = mysql_connect($AdminHost, $AdminUser, $AdminPassword);
$aDB =mysql_select_db($AdminDatabase , $link);
$smilies=array( 
    ':)' => "<img src='../smileys/smile.gif' />",
    ':(' => "<img src='../smileys/sad.gif'   />",
    ':P' => "<img src='../smileys/tongue.gif' />",
    ';)' => "<img src='../smileys/wink.gif'  />",
    ':*)' => "<img src='../smileys/embarassed.gif'  />",
    'O:]' => "<img src='../smileys/angel.gif'  />",
    '=/' => "<img src='../smileys/undecided.gif'  />",
    ':-X' => "<img src='../smileys/sealedlips.gif'  />",
    'S-)' => "<img src='../smileys/rolleyes.gif'  />",
    ':-D' => "<img src='../smileys/grin.gif'  />",
    'QQ' => "<img src='../smileys/cry.gif'  />",
    '8-)' => "<img src='../smileys/cool.gif'  />",
    '>(' => "<img src='../smileys/angry.gif'  />",
    '=O'=>  "<img src='../smileys/shocked.gif' />"
);
$brisi = $_GET['brisi'];

if ($brisi!="")
{
    $result = mysql_query(" DELETE FROM komentari WHERE id = '$brisi' LIMIT 1") or die(mysql_error());
}
$koristan = $_GET['koristan'];
if ($koristan!="")
{
    $unautora = $_GET['unautora'];
    $idfot = $_GET['idfot'];
    $aSQL  = "insert into korisnikomentari(id, username, id_komentara, id_fotografije) values ('','$unautora',$koristan,'$idfot')";
    mysql_query($aSQL) or die(mysql_error());
}  
$idkomentara = $_GET['idkomentara']; 
$result = mysql_query("SELECT * FROM komentari where id='$idkomentara'") or die(mysql_error());
$idkomentara = mysql_result($result,0,"id");
$idslike = mysql_result($result,0,"id_fotografije");

$rez = mysql_query("select username,slika from fotografija where (id = '$idslike')");
$slika = mysql_result($rez,0,"slika");
$kojesliko = mysql_result($rez,0,"username");
$putanja="../autori/" . $kojesliko . "/" . $slika; 

echo "<table border=\"0\" width=\"700\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
        <td>
        <p align=\"center\">
                        <img id=\"slikacroper\" border=\"0\" src=\"thumbxy.php?imeslike=$putanja&max_y=700&max_x=700\"></td>
    </tr>
    <tr>
        <td align=\"center\">
        <p align=\"center\">                <table border=\"0\" width=\"492\" cellspacing=\"0\" cellpadding=\"0\">
                    <tr>
                        <td colspan=\"4\">
                        &nbsp;</td>
                    </tr>";
$result = mysql_query("SELECT * FROM komentari where id_fotografije='$idslike' ORDER BY datum_vreme_upisa ASC") or die(mysql_error());
$brkomentara=mysql_num_rows($result);
for ($i = 0; $i < $brkomentara; $i++) 
{ 
    $idkomentara1 = mysql_result($result,$i,"id");
    $usernamekopise = mysql_result($result,$i,"username");
    $datum_vreme_upisa = mysql_result($result,$i,"datum_vreme_upisa");
    
    $komentar= mysql_result($result,$i,"komentar");
    $komentar=str_replace(array_keys($smilies), array_values($smilies), $komentar);
    
    $komentar = nl2br($komentar);  

    if ($idkomentara1==$idkomentara)
        $kom="<font face=\"Arial\" color=\"#FF0000\" size=\"2\">$komentar</font></td>";    
    else
        $kom="<font face=\"Arial\" color=\"#004971\" size=\"2\">$komentar</font></td>";
    
    $tmp=$usernamekopise;
    $rez = mysql_query("select * from autori where username = '$tmp'");
    if (mysql_result($rez,0,"slika") == '')
        $slikaautora="../images/defaultuser.jpg";
    else
        $slikaautora="../autori/$tmp/slike_za_profil/".mysql_result($rez,0,"slika");
   
    echo "
			        <tr>
                        <td bgcolor=\"#DCDCDC\" width=\"79\">
                        <font face=\"Arial\" color=\"#004971\" size=\"2\">
                        <span style=\"cursor:pointer\" onclick=\"window.parent.location='profilfotografa.php?autor=$usernamekopise'\">$usernamekopise</span></font></td>
                        <td bgcolor=\"#DCDCDC\" width=\"94\">&nbsp;</td>
                        <td bgcolor=\"#DCDCDC\" width=\"47\">&nbsp;</td>
                        <td bgcolor=\"#DCDCDC\" width=\"276\">
                        <p align=\"right\">
                        <font color=\"#004971\" face=\"Arial\" size=\"1\">$datum_vreme_upisa <a href=\"prikazikom.php?idkomentara=$idkomentara&koristan=$idkomentara1&unautora=$usernamekopise&idfot=$idslike\"><img border=\"0\" src=\"../images/add_comment.png\"  title=\"Komentar je koristan\" alt=\"Obrisi odmah\"></a> <a href=\"prikazikom.php?idkomentara=$idkomentara&brisi=$idkomentara1\"><img border=\"0\" src=\"../images/b_drop.png\"  title=\"Obrisi odmah\" alt=\"Obrisi odmah\"></a><span lang=\"en-us\">
                     </td>
                    </tr>
                    <tr>
                        <td bgcolor=\"#EFEFEF\" width=\"79\">
                        <p align=\"center\">
                        <font face=\"Arial\">
                        <span style=\"cursor:pointer\" onclick=\"window.parent.location='profilfotografa.php?autor=$usernamekopise'\">
                        <img border=\"0\" src=\"thumbxy.php?imeslike=$slikaautora&max_y=80&max_x=64\" align=\"left\"></span></font></td>
                        <td bgcolor=\"#EFEFEF\" width=\"409\" colspan=\"3\" valign=\"top\">
                        <p style=\"margin-top: 0; margin-bottom: 0\">
                        $kom
                    </tr>
                    <tr>
                        <td colspan=\"4\"><span lang=\"en-us\"><font size=\"1\">&nbsp;</font></span></td>
                    </tr>
                    <tr>
                        <td colspan=\"4\"><font size=\"1\">&nbsp;</font></td>
                    </tr>
                ";
}   
?>
                </table></td>
	</tr>
</table>

</body>

</html>